#ifndef __TINYSRV_CLIENT_ITEM_BASE_H__
#define __TINYSRV_CLIENT_ITEM_BASE_H__

#include "non_copyable.h"
#include "iref_object.h"
#include "client.h"

#include <vector>

namespace tinySrv
{

  class ClientItemBase
    : public IRefObject
    , public IClientCtrl
  {
  public:
    typedef std::vector<char> CharVector;
    
    ClientItemBase();
    ~ClientItemBase();
    bool CanClose() const;
    void SetSocket(int sock);
    int GetSocket() const;
    void SetUser(std::auto_ptr<IClient> user);
    void MarkForClose();
    void OnClose();
    void OnData(void const *data, int bytes);
    
    virtual void CloseMe();
    virtual bool SendData(void const *data, int *bytes);
    
  private:
    bool volatile MarkedForClose;
    int Socket;
    std::auto_ptr<IClient> User;
  };
  
}

#endif  // !__TINYSRV_CLIENT_ITEM_BASE_H__
